#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        int c = 0, t = x;
        while(t > 0){
            t = t / 10;
            c++;
        }
        int sum = 0;
        t = x;
        while(t > 0){
            int b = t % 10;
            t = t / 10;
            sum += pow(b, c);
        }
        if (sum == x) cout << "T" << endl;
        else cout << "F" << endl;
    }
    return 0;
}